package com.cw.jeeyt.service.converter.process;

import java.util.ArrayList;
import java.util.List;

import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.cw.jeeyt.service.bo.process.ActDeModelRelationBo;
import com.cw.jeeyt.dao.model.process.ActDeModelRelationDo;
import com.cw.lang.common.utils.CollectionUtil;

/**
 * 流程定义模型关联转换类
 *
 * @author chenw
 * @date 2019-03-10 21:47:04
 */
public class ActDeModelRelationConverter {

    /**
     * do转bo
     *
     * @param model
     * @return
     */
    public static ActDeModelRelationBo do2Bo(ActDeModelRelationDo model) {
        if (model == null) {
            return null;
        }
        ActDeModelRelationBo bo = new ActDeModelRelationBo();
        bo.setId(model.getId());
        bo.setParentModelId(model.getParentModelId());
        bo.setModelId(model.getModelId());
        bo.setRelationType(model.getRelationType());
        return bo;
    }

    /**
     * bo转do
     *
     * @param bo
     * @return
     */
    public static ActDeModelRelationDo bo2Do(ActDeModelRelationBo bo) {
        if (bo == null) {
            return null;
        }
        ActDeModelRelationDo model = new ActDeModelRelationDo();
        model.setId(bo.getId());
        model.setParentModelId(bo.getParentModelId());
        model.setModelId(bo.getModelId());
        model.setRelationType(bo.getRelationType());
        return model;
    }

    /**
     * doList转boList
     *
     * @param doList
     * @return
     */
    public static List<ActDeModelRelationBo> doList2BoList(List<ActDeModelRelationDo> doList) {
        if (CollectionUtil.isEmpty(doList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(), ActDeModelRelationConverter::do2Bo));
    }

    /**
     * boList转doList
     *
     * @param boList
     * @return
     */
    public static List<ActDeModelRelationDo> boList2DoList(List<ActDeModelRelationBo> boList) {
        if (CollectionUtil.isEmpty(boList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(), ActDeModelRelationConverter::bo2Do));
    }
}